package org.jsets.fastboot.uid.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import lombok.Data;

/**
 * 
 * UidGenerator配置
 * 
 * @author wj596
 * 
 * 对于并发数要求不高、期望长期使用的应用, 可增加timeBits位数, 减少seqBits位数.
 * 例如节点采取用完即弃的WorkerIdAssigner策略, 重启频率为12次/天,
 * 那么配置成{"workerBits":23,"timeBits":31,"seqBits":9}时,
 * 可支持28个节点以整体并发量14400 UID/s的速度持续运行68年.
 * 
 * 对于节点重启频率频繁、期望长期使用的应用, 可增加workerBits和timeBits位数, 减少seqBits位数.
 * 例如节点采取用完即弃的WorkerIdAssigner策略, 重启频率为24*12次/天,
 * 那么配置成{"workerBits":27,"timeBits":30,"seqBits":6}时, 可支持37个节点以整体并发量2400
 * UID/s的速度持续运行34年.
 * 
 */
@Data
@ConfigurationProperties(prefix = UidGeneratorProperties.PREFIX)
public class UidGeneratorProperties {

	public static final String PREFIX = "uidgenerator";
	
	private static final String WORKER_ID_PROVIDER_ASSIGNED = "assigned";
	private static final String WORKER_ID_PROVIDER_JDBC = "jdbc";
	private static final String WORKER_ID_PROVIDER_DATASOURCE = "datasource";

	private static final int WORKER_BITS = 23;
	private static final int TIME_BITS = 31;
	private static final int SEQ_BITS = 9;

	// assigned： 直接指定
	// jdbc： JDBC
	// datasource： 系统数据源
	// private String workerIdProvider;

	
	private boolean enabled;// 是否启用
	
	private Long workerId;// 直接指定的 workerId
	private int workerBits = WORKER_BITS;
	private int timeBits = TIME_BITS;
	private int seqBits = SEQ_BITS;
	private String epochStr = "2021-08-10";
	private int boostPower = 0;
	private int paddingFactor = 0;
	private int scheduleInterval = 0;

	private String driverClassName;
	private String url;
	private String username;
	private String password;
	private String schema;

	private String addrs;
	private String authentication;
	private int sessionTimeoutMs = 15000;
}
